package com.clouddot.baipai.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.clouddot.baipai.R;
import com.clouddot.baipai.http.entity.response.getAllClassResponse;
import com.clouddot.baipai.http.entity.response.getLeaveTypeResponse;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by wxy on 2018/7/16.
 */

public class AllClassAdapter extends BaseAdapter {
    List<getAllClassResponse> datas = new ArrayList<getAllClassResponse>();
    Context mContext;

    public AllClassAdapter(Context context) {
        this.mContext = context;
    }

    public void setDatas(ArrayList<getAllClassResponse> datas) {
        this.datas = datas;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return datas == null ? 0 : datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas == null ? null : datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHodler hodler = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.h_adapter_spinner_item, parent, false);
            hodler = new ViewHodler(convertView);

            convertView.setTag(hodler);
        } else {
            hodler = (ViewHodler) convertView.getTag();
        }

        hodler.mTextView.setText(datas.get(position).getGradeClassName());

        return convertView;
    }

    private static class ViewHodler {
        TextView mTextView;

        public ViewHodler(View view) {
            mTextView = view.findViewById(R.id.txt);

        }
    }

}
